#!/bin/sh
ipaddr=$(uci -q get network.lan.ipaddr)
[  -n  "$(uci -q get netwizard.default=netwizard)" ] && uci set netwizard.default=netwizard
uci -q set netwizard.default.wifi_ssid="$(uci -q get wireless.@wifi-iface[0].ssid)"
uci -q set netwizard.default.wifi_key="$(uci -q get wireless.@wifi-iface[0].key)"
[ "$(uci -q get network.wan.proto)" ] && uci -q set netwizard.default.wan_proto="$(uci -q get network.wan.proto)" || uci -q set netwizard.default.wan_proto="siderouter"
uci -q set netwizard.default.lan_ipaddr="${ipaddr}"
uci -q set netwizard.default.lan_netmask="$(uci -q get network.lan.netmask)"
uci -q set netwizard.default.lan_gateway="${ipaddr%.*}"
uci -q set netwizard.default.lan_dns="$(uci -q get network.lan.dns)"
uci -q set netwizard.default.wan_interface=`uci -q get network.wan.ifname  || uci -q get network.wan.device`
[ "$(uci -q get dhcp.lan.ignore)" ] && uci -q set netwizard.default.lan_dhcp="0" || uci -q set netwizard.default.lan_dhcp="1" 
uci commit netwizard
exit 0
